package com.lx.sort.cmp;

import com.lx.sort.Sort;

/**
 * @author sir
 */
public class SelectionSort<T extends Comparable<T>> extends Sort<T> {
	@Override
	protected void sort() {
		for (int begin = 0; begin < array.length-1; begin++) {
			int min = begin;
			for (int end = begin + 1; end < array.length; end++) {
				if (cmp(min, end) > 0) {
					min = end;
				}
			}
			if (min!=begin){
				swap(min, begin);
			}
		}
	}
}
